import React, {Component} from 'react'
import { Button, Text, SafeAreaView } from 'react-native'

class DetailPage extends Component {
    constructor(props){
        super(props)
    }
    //静态方法navigationOptions会被放进当前路由的配置之中
    static navigationOptions = ({navigation}) => {
        return {
            headerLeft: (
                <Button title="拦截后退" onPress={() => {
                    navigation.navigate('HomePage')
                }}></Button>
            )
        }
    }

    render(){
        return (
            <SafeAreaView>
                <Text>detail</Text>
                {/* <Text>获取到的参数：{this.props.navigation.state.params.name}</Text> */}
                <Button
                    title="Go Back"
                    onPress={() => {
                        this.props.navigation.goBack()
                    }}
                ></Button>
                <Button
                    title="改变参数"
                    onPress={() => {
                        this.props.navigation.setParams({
                            name: '改变了hanhan'
                        })
                    }}
                ></Button>
            </SafeAreaView>
        )
    }
}

export default DetailPage